home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Palettes / MiscCircularSlider / MiscCircularSlider.subproj / MiscCircularSlider.m < prev    next >
Encoding:
Text File  |  1995-07-06  |  4.5 KB  |  240 lines

  1. //
  2. //    MiscCircularSlider.m -- a cover for the MiscCircularSliderCell class
  3. //        Written by Vince DeMarco and Don Yacktman
  4. //        Copyright (c) 1994 by Vince DeMarco and Don Yacktman.
  5. //                Version 1.0  All rights reserved.
  6. //        This notice may not be removed from this source code.
  7. //
  8. //    This object is included in the MiscKit by permission from the author
  9. //    and its use is governed by the MiscKit license, found in the file
  10. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  11. //    for a list of all applicable permissions and restrictions.
  12. //    
  13.  
  14. // This was created by modifying Vince's CircularSlider class and
  15. // merging it with Don's RotationSlider class.  Here's the info
  16. // from the original files.
  17. /*
  18.  *    Filename: CircularSlider.m
  19.  *    Created : Sat 24 21:25:44 1991
  20.  *    Author  : Vince DeMarco <vince@whatnxt.cuc.ab.ca>
  21.  *    LastEditDate Was "Mon Sep  6 16:32:15 1993"
  22.  *
  23.  *    Version 2.0
  24.  */
  25. //    RotationSlider.m -- written by Don Yacktman
  26. //    Copyright 1993 by Don Yacktman.  All rights reserved.
  27.  
  28. //    Modified by Laurent Daudelin <laurent@planon.qc.ca> to add
  29. //  support for the lower and upper stop values and
  30. //  the boundary flag.
  31.  
  32. #import "MiscCircularSlider.h"
  33.  
  34. static id MiscCircularSliderCellClass;
  35.  
  36. @implementation MiscCircularSlider
  37.  
  38. + initialize
  39. {
  40.     if (self == [MiscCircularSlider class]) {
  41.         MiscCircularSliderCellClass = [MiscCircularSliderCell class];
  42.         // the default class
  43.     }
  44.     return self;
  45. }
  46.  
  47. + setCellClass:classId
  48. {
  49.     MiscCircularSliderCellClass = classId;
  50.     return self;
  51. }
  52.  
  53. - initFrame:(NXRect *)nf
  54. {
  55.     [super initFrame:nf];
  56.     [[self setCell:[[MiscCircularSliderCellClass alloc] init]] free];
  57.     return self;
  58. }
  59.  
  60. - setBezeled:(BOOL)value
  61. {
  62. //    BOOL old = [cell isBezeled];
  63. //    [cell setBezeled:value];
  64. //   if (old != value) [self display];
  65.     return self;
  66. }
  67.  
  68. - (BOOL)isBezeled
  69. {
  70.     return [cell isBezeled];
  71. }
  72.  
  73. - setBordered:(BOOL)value
  74. {
  75. //    BOOL old = [cell isBordered];
  76. //   [cell setBordered:value];
  77. //    if (old != value) [self display];
  78.     return self;
  79. }
  80.  
  81. - (BOOL)isBordered
  82. {
  83.     return [cell isBordered];
  84. }
  85.  
  86. - setJumpToMousePoint:(BOOL)aBOOL
  87. {
  88.     [cell setJumpToMousePoint:aBOOL];
  89.     return self;
  90. }
  91.  
  92. - (BOOL)jumpToMousePoint
  93. {
  94.     return [cell jumpToMousePoint];
  95. }
  96.  
  97. - setHidden:(BOOL)aBOOL
  98. {
  99.     BOOL old = [cell hidden];
  100.     [cell setHidden:aBOOL];
  101.     if (aBOOL != old) [self display];
  102.     return self;
  103. }
  104.  
  105. - (BOOL)hidden
  106. {
  107.     return (BOOL)[cell hidden];
  108. }
  109.  
  110. - setUpperStopValue:(float)aValue
  111. {
  112.     float oldValue = [cell upperStopValue];
  113.     [cell setUpperStopValue:aValue];
  114.     if (aValue != oldValue) [self display];
  115.     return self;
  116. }
  117.  
  118. - (float)upperStopValue
  119. {
  120.     return [cell upperStopValue];
  121. }
  122.  
  123. - setLowerStopValue:(float)aValue
  124. {
  125.     float oldValue = [cell lowerStopValue];
  126.     [cell setLowerStopValue:aValue];
  127.     if (aValue != oldValue) [self display];
  128.     return self;
  129. }
  130.  
  131. - (float)lowerStopValue
  132. {
  133.     return [cell lowerStopValue];
  134. }
  135.  
  136. - setUseBoundaries:(BOOL)flag
  137. {
  138.     [cell setUseBoundaries:flag];
  139.     return self;
  140. }
  141.  
  142. - (BOOL)useBoundaries
  143. {
  144.     return [cell useBoundaries];
  145. }
  146.  
  147. - setSliderStyle:(MiscCircularSliderStyle)style
  148. {
  149.     MiscCircularSliderStyle old = [cell sliderStyle];
  150.     [cell setSliderStyle:style];
  151.     if (style != old) [self display];
  152.     return self;
  153. }
  154.  
  155. - (MiscCircularSliderStyle)sliderStyle
  156. {
  157.     return (MiscCircularSliderStyle)[cell sliderStyle];
  158. }
  159.  
  160. - setSliderPathWidth:(float)value
  161. {
  162.     [cell setSliderPathWidth:value];
  163.     return self;
  164. }
  165.  
  166. - (float)sliderPathWidth
  167. {
  168.     return [cell sliderPathWidth];
  169. }
  170.  
  171. - setBorderType:(int)type
  172. {
  173.     int old = [cell sliderStyle];
  174.     [cell setBorderType:type];
  175.     if (type != old) [self display];
  176.     return self;
  177. }
  178. - (int)borderType
  179. {
  180.     return [cell borderType];
  181. }
  182.  
  183. - setBackgroundColor:(NXColor)aColor
  184. {
  185.     NXColor old = [cell backgroundColor];
  186.     [cell setBackgroundColor:aColor];
  187.     if (!NXEqualColor(old,aColor)) [self display];
  188.     return self;
  189. }
  190. - (NXColor)backgroundColor
  191. {
  192.     return [cell backgroundColor];
  193. }
  194.  
  195. - (float)startAngle
  196. {
  197.     return [cell startAngle];
  198. }
  199.  
  200. - setStartAngle:(float)ang
  201. {
  202.     [cell setStartAngle:ang];
  203.     [self display];
  204.     return self;
  205. }
  206.  
  207. - (BOOL)isClockwise
  208. {
  209.     return [cell isClockwise];
  210. }
  211.  
  212. - setClockwise:(BOOL)clockwise
  213. {
  214.     [cell setClockwise:clockwise];
  215.     [self display];
  216.     return self;
  217. }
  218.  
  219. @end
  220.  
  221.  
  222. @implementation MiscCircularSlider(Compatability)
  223.  
  224. // Two covers to make sure we implement the methods that were used by Vince's
  225. // CircularSlider.  This way, code that used that slider will still work as
  226. // it did before with this new class dropped in instead.
  227.  
  228. - setDrawAsPieChart:(BOOL)aBOOL
  229. {
  230.     return [self setSliderStyle:
  231.             (aBOOL ? MISC_PIECHART_STYLE : MISC_DIAL_STYLE)];
  232. }
  233.  
  234. - (BOOL)drawAsPieChart
  235. {
  236.     return (BOOL)([self sliderStyle] == MISC_PIECHART_STYLE);
  237. }
  238.  
  239. @end
  240.